﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 获取招聘信息列表JSON
    /// </summary>
    public partial class GetRecruitmentListJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datas = new List<object>();
            var post = Fq("CoPost").SafeToString();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();
            var recruitmentService = new RecruitmentService();
            var table = recruitmentService.GetTable(post, pageValue, rowsValue);
            object result = new { total = table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoRecruitmentId"].SafeToInt(),
                    CoPost = table.Rows[i]["CoPost"].SafeToString(),
                    CoNumber = table.Rows[i]["CoNumber"].SafeToString(),
                    CoAge = table.Rows[i]["CoAge"].SafeToString(),
                    CoAssess = table.Rows[i]["CoAssess"].SafeToString(),
                    CoDate = table.Rows[i]["CoDate"].SafeToDateTime().ToString("yyyy-MM-dd"),
                    CoValidDate = table.Rows[i]["CoValidDate"].SafeToDateTime().ToString("yyyy-MM-dd"),
                });
            }
            Json(result);
        }
    }
}